import { request } from '@/utils/request';

export function fetchList(query?: Object) {
  return request({
    url: '/pm/experimentReport/page',
    method: 'GET',
    query,
  });
}

export const getObj = (query?: any) => {
  return request<{ data: any }>({
    url: `/pm/experimentReport/` + query.id,
    method: 'GET',
  });
};

export function putObj(obj?: any) {
  return request({
    url: '/pm/experimentReport',
    method: 'PUT',
    data: obj,
  });
}

export const updateByIdEvery = (data?: any) => {
  return request<{ data: any }>({
    url: '/pm/experimentReport/sign',
    method: 'POST',
    data: data,
  });
};

/**
 * 通过实验记录id查询方案相关信息
 * @param id
 * @returns
 */
export function getSchemeInfoByRecord(id?: string) {
  return request({
    url: '/pm/experimentReport/getSchemeInfoByRecordId/' + id,
    method: 'GET',
  });
}

/**
 * 通过recordId查询用料明细
 * @param id
 * @returns
 */

export function getDosageByRecord(recordId?: string) {
  return request({
    url: '/pm/experimentReport/getDosageByRecordId/' + recordId,
    method: 'GET',
  });
}

/**
 * 通过实验记录id查询记录相关信息
 * @param id
 * @returns
 */
export function getExperimentRecord(id?: string) {
  return request({
    url: '/pm/experimentRecord/' + id,
    method: 'GET',
  });
}

/**
 * 获取任务信息
 * @param id
 * @returns
 */
export function getRdTaskDetail(query) {
  return request({
    url: '/pm/experimentReport/getRdTaskDetail',
    method: 'GET',
    query: query,
  });
}


/**
 * 通过实验记录id查询检验报告
 * @param id
 * @returns
 */
export function getQcMiddleReport(id) {
  return request({
    url: '/pm/qcMiddleReport/getInfoByRecord/' + id,
    method: 'GET',
  });
}


/**
 * 撤回
 * @param obj
 * @returns
 */
export function revokeProcess(obj?) {
  return request({
    url: '/pm/experimentReport/revoke',
    method: 'POST',
    data: obj,
  });
}

/**
 * 同意
 * @param obj
 * @param id
 * @returns
 */
export function complete(obj?: Object, id?: string) {
  return request({
    // url: '/pm/experimentScheme/complete',
    url: '/pm/experimentReport/complete?id=' + id,
    method: 'POST',
    data: obj,
  });
}

/**
 * 弃审
 * @param obj
 * @returns
 */
export function abandon(obj?: any) {
  return request({
    url: `/pm/experimentReport/abandon?comment=${obj.comment}`,
    method: 'POST',
    data: obj,
  });
}